#include <iostream>
#include<string>
using namespace std;

int main() {
    string s;
    cin>>s;
    int ans;
    int left=0,right=s.size()-1;
    while(left<right){
        if(s[left]!=s[right]) {ans=right-left+1;
        break;
        }
        else {
            if(s[left+1]!=s[right-1]) {ans=right-left+1;
            break;
            }
            else --right;
        }
    }
    
    cout<<ans<<endl;
    return 0;
}
